<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="../assets/css/font-awesome.css" rel="stylesheet" />
    <link href="../css/pulic.css" rel="stylesheet"/>
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <!-- TABLE STYLES-->
    <link href="../assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <script src="../js/layui/layui.js"></script>
    <script src="../js/jquery-3.2.1/jquery-3.2.1.js"></script>
    <style media="screen">
        .ECalendar{width:120px;height:30px;}
    </style>
</head>
<body>
<!--<div class="panel panel-default">-->

		<div class="panel-heading">
			<h1 class="page-header">
                  	我的已办
              </h1>
		</div>
<div class="row" style="margin-left: 2%;">
    <form class="form-inline" >
        <div class="form-group">
            <input type="text" class="form-control" id="workdone_choose_userName" placeholder="请输入名字">
        </div>
        <div class="form-group" style="margin-left: 1%;">
            <input type="text" class="form-control" id="workdone_choose_moneyStart" placeholder="请输入金额"> -
            <input type="text" class="form-control" id="workdone_choose_moneyEnd" placeholder="请输入金额">
        </div>
        <div class="form-group" style="margin-left: 1%;">
            <input type="date" class="form-control" id="workdone_choose_startTime" placeholder="请输入日期"> -
            <input type="date" class="form-control" id="workdone_choose_endTime" placeholder="请输入日期">
        </div>
        <button type="button" class="btn btn-info" id="workdone_choose">搜索</button>
    </form>
</div>
<div class="panel-body">
    <div class="table-responsive">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>已办名称</th>
                <th>来源</th>
                <th>金额</th>
                <th>申请时间</th>
                <th>当前环节</th>
            </tr>
            </thead>
            <tbody id="det">
            <c:forEach items="${workdonelist }" var="work">
            <tr class="det" >
	           <td style="display: none" class="reimbursementId">${work.reimbursementId }</td>
               <td class="reimbursementTypeName">${work.reimbursementTypeName }-${work.userName }</td>
               <td>${work.reimbursementsource }</td>
               <td>${work.reimbursementMoney}</td>
               <td>${work.reimbursementTime }</td>
               <td>${work.roleName }</td>
	        </tr>
	        </c:forEach>
            </tbody>
        </table>
    </div>
</div>

 					 <!--分页功能-->
                         <div class="row" style="margin-left: 25%;margin-bottom:1%">
                   	<div class="col-sm-6">
                   		<div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
                   			<ul class="pagination">
                   				<li class="paginate_button previous" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_previous">
                   					<a href="myWorkDone.do?pageNow=1">首页</a>
                   				</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
								  <c:choose> 
								   <c:when test="${page.pageNow - 1 > 0}"> 
								    <a href="myWorkDone.do?pageNow=${page.pageNow - 1}" rel="external nofollow" >上一页</a> 
								   </c:when> 
								   <c:when test="${page.pageNow - 1 <= 0}"> 
								    <a href="myWorkDone.do?pageNow=1" rel="external nofollow" rel="external nofollow" >上一页</a> 
								   </c:when> 
								  </c:choose> 
								</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
									<a>第 ${page.pageNow} 页</a>
								</li>
								<li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
									<c:choose> 
									<c:when test="${page.totalPageCount==0}"> 
										<a href="myWorkDone.do?pageNow=${page.pageNow}" rel="external nofollow" rel="external nofollow" >下一页</a> 
									</c:when> 
									<c:when test="${page.pageNow + 1 < page.totalPageCount}"> 
									    <a href="myWorkDone.do?pageNow=${page.pageNow + 1}" rel="external nofollow" >下一页</a> 
									</c:when> 
									<c:when test="${page.pageNow + 1 >= page.totalPageCount}"> 
									    <a href="myWorkDone.do?pageNow=${page.totalPageCount}" rel="external nofollow" rel="external nofollow" >下一页</a> 
									</c:when> 
									</c:choose> 
								</li>
								<li class="paginate_button next" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_next">
								  <c:choose> 
								   <c:when test="${page.totalPageCount==0}"> 
								    <a href="myWorkDone.do?pageNow=${page.pageNow}" rel="external nofollow" rel="external nofollow" >尾页</a> 
								   </c:when> 
								   <c:otherwise> 
								    <a href="myWorkDone.do?pageNow=${page.totalPageCount}" rel="external nofollow" rel="external nofollow" >尾页</a> 
								   </c:otherwise> 
								  </c:choose> 
								</li>
                   			</ul>
                   		</div>
                   	</div>
                   </div>
</body>

<script src="../assets/js/jquery-1.10.2.js"></script>
<!-- Bootstrap Js -->
<script src="../assets/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="../assets/js/jquery.metisMenu.js"></script>
<!-- DATA TABLE SCRIPTS -->
<script src="../assets/js/dataTables/jquery.dataTables.js"></script>
<script src="../assets/js/dataTables/dataTables.bootstrap.js"></script>
 <script src="../js/Ecalendar.jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $('#dataTables-example').dataTable();
    });

    layui.use('layer', function(){
        var layer = layui.layer;
    });

    $('.det').on('click', function(){
    	var reimbursementId = $(this).closest("tr").find(".reimbursementId").text();//报销id
    	var reimbursementTypeName = $(this).closest("tr").find(".reimbursementTypeName").text(); //报销类型名
    	console.log(reimbursementTypeName);
    	console.log(reimbursementId);

        layer.open({
            type: 2,
            title: '详细信息',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area : ['80%' , '80%'],
            content: ['${pageContext.request.contextPath}/work/listWorkMsgDetails.do?reimbursementId='+reimbursementId+'&reimbursementTypeName='+reimbursementTypeName+'','yes']
        });
    });
    
    $("#workdone_choose").click(function(){
    	var userName = $("#workdone_choose_userName").val();
    	var startMoney = $("#workdone_choose_moneyStart").val();
    	var endMoney = $("#workdone_choose_moneyEnd").val();
    	var startTime = $("#workdone_choose_startTime").val();
    	var endTime = $("#workdone_choose_endTime").val();
    	console.log(userName);
    	console.log(startMoney);
    	console.log(endMoney);
    	console.log(startTime);
    	console.log(endTime);
    	if(userName == '' && startMoney == '' && endMoney == '' && startTime == '' && endTime == ''){
    		layer.msg("请输入查询条件！");
    	}else{
    	
    	var chooseJson = {
    		"userName":userName,
    		"startMoney":startMoney,
    		"endMoney":endMoney,
    		"startTime":startTime,
    		"endTime":endTime
    	}
		    	$.ajax({
					type:"post",
					url:"${pageContext.request.contextPath}/work/chooseWorkDone.do",
					dataType:"json",
					data:chooseJson,
					success:function(data){
						console.log(data);
						if(data == ''){
							layer.msg("查无此数据！");
						}else{
							//layer.msg("!!！");
							$("#det").children().remove();
							var str = '';
							$.each(data,function(key,val){
								str += '<tr>'
									+'<td style="display: none" class="reimbursementId">'+val.reimbursementId+'</td>'
					                + '<td class="reimbursementTypeName">'+val.reimbursementTypeName+'-'+val.userName+'</td>'
					               	+'<td>'+val.reimbursementsource+'</td>'
					               	+'<td>'+val.reimbursementMoney+'</td>'
					               	+'<td>'+getMyDate(val.reimbursementTime) +'</td>'
					               	+'<td>'+val.roleName +'</td>'
					               	+'</tr>'
							});
							$("#det").append(str);
						}
						
					},
					error:function(){
						console.log("我错了");
					}
				});
    	}
});

    //str为传入的字符串为毫秒值
    function getMyDate(str){  
          var oDate = new Date(str),  
          oYear = oDate.getFullYear(),  
          oMonth = oDate.getMonth()+1,  
          oDay = oDate.getDate(),  
          oHour = oDate.getHours(),  
          oMin = oDate.getMinutes(),  
          oSen = oDate.getSeconds(),  
          oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);
          //最后拼接时间为 1999-10-02 11:23:01样式 
          return oTime;  
      };  
    //补0操作  
      function getzf(num){  
          if(parseInt(num) < 10){  
              num = '0'+num;  
          }  
          return num;  
      }  
   
</script>

<!-- Custom Js -->
<!-- <script src="../assets/js/custom-scripts.js"></script>-->


</html>